package com.yzl.springboot.springboot.controller;

import com.yzl.springboot.springboot.config.WXConfig;
import com.yzl.springboot.springboot.utils.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.crypto.SecretKey;
import java.util.HashMap;
import java.util.Map;

/**
 * @Title: TestController
 * @Author: 姚志立
 * @Description:
 * @Date: 2020/5/24 22:33
 * @Version: 1.0
 */

@RestController
@RequestMapping("api/v1/test")
@PropertySource("classpath:pay.properties")
public class TestController {
    @Value("${wxpay.id}")
    private String payAppId;
    @Value("${wxpay.sercret}")
    private String paySecret;
    @Autowired
    private WXConfig wxConfig;

    @GetMapping("list")
    public JsonData testExt(){
        int i=1/0;
        return JsonData.buildSuccess("");

    }

    @GetMapping("get_config")
    public JsonData testConfig() {
        Map<String, Object> map = new HashMap<>();
//        map.put("appid",payAppId);
//        map.put("secret", paySecret);
//        return JsonData.buildSuccess(map);
        map.put("appid", wxConfig.getPayAppId());
        map.put("secret",wxConfig.getPaySecret() );
        map.put("mechid",wxConfig.getPayMechId() );
        return JsonData.buildSuccess(map);
    }
}
